<script type="text/php">
    if ( isset($pdf) ) {

    // Open the object: all drawing commands will
    // go to the object instead of the current page
    $footer = $pdf->open_object();

    $w = $pdf->get_width();
    $h = $pdf->get_height();

    // Draw a line along the bottom
    $y = $h - 2 * $text_height - 24;
    $pdf->line(36, $y, $w - 36, $y, $color, 1);

    $pdf->page_text($w - 140, $y + 5, "Halaman {PAGE_NUM} dari {PAGE_COUNT}", $font, 10, array(0,0,0));
    $pdf->page_text($w - 220, 18, date("H:i:s d/m/Y")." dari AddPro", $font, 10, array(0,0,0));
    $img_w = 996; // 2 inches, in points
    $img_h = 370; // 1 inch, in points -- change these as required
    $pdf->image(base_url()."/assets/default/addprologotrans.png", "png", 20, $w, $img_h, $img_w);
    $pdf->image(base_url()."/assets/default/addprologotrans.png", "png", 385, $w, $img_h, $img_w);
    $pdf->image(base_url()."/assets/default/addprologotrans.png", "png", 750, $w, $img_h, $img_w);

    // Close the object (stop capture)
    $pdf->close_object();

    // Add the object to every page. You can
    // also specify "odd" or "even"
    $pdf->add_object($footer, "all");
    }
</script>
<style>
    @page { margin: 70px 50px; }
    body,h2,h3 {
        font-family: 'dotmatri';
    }
    body {
        font-size: 15px;
    }
    table.equalDevide tr td { width: 50%; }
</style>

<div style="width: 100%" align="center"><h3><b>STOK <?= ($kategori == 'rab' ? 'RAB' : 'GUDANG') ?></b></h3></div>
<table class="table table-bordered centerTable" style="font-size: 12px">
    <thead>
        <tr class="label-info" style="">
            <th colspan="2">Keterangan <?= ($kategori == 'rab' ? 'RAB' : 'Gudang') ?></th>
        </tr>
    </thead>
    <tbody>
        <?php if ($kategori == 'rab') {
            ?>
            <tr>
                <td width="100" class="ket_po"><b>Main Project</b></td>
                <td><?= $deskripsi_kategori['MAIN_PROJECT_KODE'] ?> <?= $deskripsi_kategori['MAIN_PROJECT_NAMA'] ?></td>
            </tr>
            <tr>
                <td width="100" class="ket_po"><b>Project</b></td>
                <td><?= $deskripsi_kategori['PROJECT_KODE'] ?> <?= $deskripsi_kategori['PROJECT_NAMA'] ?></td>
            </tr>
            <tr>
                <td width="100" class="ket_po"><b>RAB</b></td>
                <td><?= $deskripsi_kategori['RAB_KODE'] ?> <?= $deskripsi_kategori['RAB_NAMA'] ?></td>
            </tr>
            <?php
        } else if ($kategori == 'gudang') {
            ?>
            <tr>
                <td width="100" class="ket_po"><b>Kode</b></td>
                <td><?= $deskripsi_kategori['GUDANG_KODE'] ?> </td>
            </tr>
            <tr>
                <td width="100" class="ket_po"><b>Nama</b></td>
                <td><?= $deskripsi_kategori['GUDANG_NAMA'] ?> </td>
            </tr>
            <tr>
                <td width="100" class="ket_po"><b>Alamat</b></td>
                <td><?= $deskripsi_kategori['GUDANG_LOKASI'] ?> </td>
            </tr>
            <?php
        }
        ?>
    </tbody>
</table>

<table class="table table-striped table-bordered table-hover centerTable" style="margin-top: 20px; font-size: 10px">
    <thead>
        <tr class="label-info">
            <th colspan="7">Daftar Stok</th>
        </tr>
        <tr class="label-info">
            <th>No.</th>
            <th>Kode Barang</th>
            <th>Nama Barang</th>
            <th>Jumlah Stok</th>
            <th>Satuan</th>
            <th>Harga Satuan</th>
            <th>Nilai Aset</th>
        </tr>
    </thead>
    <tbody id="">
        <?php
        $count = 0;
        foreach ($list_barang as $mtrl) {
            $count++;
            ?>
            <tr style="height: 5px; padding: 0px;margin: 0px;">
                <td><?= $count ?></td>
                <td><?= $mtrl['KODE_MATERIAL'] ?></td>
                <td><?= $mtrl['NAMA_MATERIAL'] ?></td>
                <td><?= $mtrl['VOLUME'] ?></td>
                <td><?= $mtrl['SATUAN_MATERIAL'] ?></td>
                <td>Rp. <?= number_format(((double)$mtrl['NILAI_ASET'] / (double)$mtrl['VOLUME']),2) ?></td>
                <td>Rp. <?= number_format((double)$mtrl['NILAI_ASET'],2) ?></td>
            </tr>
            <?php
        }
        ?>
    </tbody>
</table>

<style type="text/css">
    .centerTable tbody tr td{
        height: 10px;
    }
    .centerTable th{
        text-align: center;
        background-color: #0993D3;
        color: #FFFFFF;
        height: 15px;
        font-size: 12px;
    }
    .ket_po{
        background-color: #EEEEEE;
    }
</style>